/**
 * Copyright &copy; 2012-2016 <a href="https://istep.lczyfz.com">Istep</a> All rights reserved.
 */
package com.lczyfz.istep.modules.resource.service;

import java.util.List;

import com.lczyfz.istep.common.constants.DeleteFlag;
import com.lczyfz.istep.modules.resource.entity.ResourceCourse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lczyfz.istep.common.persistence.Page;
import com.lczyfz.istep.common.service.CrudService;
import com.lczyfz.istep.modules.resource.entity.ResourcePaper;
import com.lczyfz.istep.modules.resource.dao.ResourcePaperDao;

/**
 * 试卷管理Service
 * @author dh
 * @version 2017-01-15
 */
//fdsaf
@Service
@Transactional(readOnly = true)
public class ResourcePaperService extends CrudService<ResourcePaperDao, ResourcePaper> {

	@Autowired
	ResourcePaperDao resourcePaperDao;

	public ResourcePaper get(String id) {
		return super.get(id);
	}
	
	public List<ResourcePaper> findList(ResourcePaper resourcePaper) {
		return super.findList(resourcePaper);
	}
	
	public Page<ResourcePaper> findPage(Page<ResourcePaper> page, ResourcePaper resourcePaper) {
		return super.findPage(page, resourcePaper);
	}
	
	@Transactional(readOnly = false)
	public void save(ResourcePaper resourcePaper) {
		super.save(resourcePaper);
	}
	
	@Transactional(readOnly = false)
	public void delete(ResourcePaper resourcePaper) {
		super.delete(resourcePaper);
	}

	//添加下发-根据试卷id获取CTF题目集
	public List<ResourcePaper> findPaperById(String trainProgramId){
		if( trainProgramId == null || trainProgramId.equals("") ){
			return resourcePaperDao.findList(new ResourcePaper());
		}else {
			return resourcePaperDao.findPaperById(trainProgramId, DeleteFlag.deleteFlag);
		}
	}

	/**
	 *根据课程体系id查询试卷列表
	 * @param page
	 * @param resourcePaper
	 * @return
	 */
	public Page<ResourcePaper> findPageByTrainprogramId(Page<ResourcePaper> page, ResourcePaper resourcePaper) {
		resourcePaper.setPage(page);
		page.setList(dao.findPageByTrainprogramId(resourcePaper));
		return page;
	}
	public ResourcePaper findPaperByPaperName(ResourcePaper resourcePaper) {

			return dao.findPaperByPaperName(resourcePaper);
	}

	//我的学习任务-获取试卷名称
	public List<ResourcePaper> stuLearnPaper(String distributeId, String userId){
		return resourcePaperDao.stuLearnPaper(distributeId, userId, DeleteFlag.deleteFlag);
	}
}